package com.koron.order.workbench.homeCard.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.order.workbench.homeCard.bean.dto.HomeCardDto;
import com.koron.order.workbench.homeCard.bean.po.HomeCardPo;
import com.koron.order.workbench.homeCard.service.HomeCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 小组件卡片表(HomeCard)表控制层
 *
 * @author zhouj
 * @since 2022-03-18 10:19:36
 */
@Api(tags = "小组件卡片表(HomeCard)")
@RestController
@RequestMapping("/homeCard/")
public class HomeCardController {

    @Autowired
    private HomeCardService homeCardService;

    @ApiOperation(value = "新增或修改小组件卡片表")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody HomeCardPo homeCard) {
        return Response.ok(ADOConnection.runTask(homeCardService, "insertOrUpdate", Integer.class, homeCard));
    }

    @ApiOperation(value = "新增小组件卡片表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody HomeCardPo homeCard) {
        return Response.ok(ADOConnection.runTask(homeCardService, "insert", Integer.class, homeCard));
    }

    @ApiOperation(value = "批量新增小组件卡片表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody HomeCardDto homeCardDto) {
        return Response.ok(ADOConnection.runTask(homeCardService, "insertBatch", Integer.class, homeCardDto));
    }

    @ApiOperation(value = "根据id更新小组件卡片表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody HomeCardPo homeCard) {
        return Response.ok(ADOConnection.runTask(homeCardService, "update", Integer.class, homeCard));
    }

    @ApiOperation(value = "根据id删除小组件卡片表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(homeCardService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询小组件卡片表")
    @GetMapping("queryById")
    public Response<HomeCardPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(homeCardService, "queryById", HomeCardPo.class, id));
    }

    @ApiOperation(value = "不分页查询小组件卡片表列表")
    @GetMapping("queryList")
    public Response<List> queryList(HomeCardPo queryVo) {
        return Response.ok(ADOConnection.runTask(homeCardService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询小组件卡片表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(HomeCardPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(homeCardService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
